package com.seezoon.application.device.executor;

import com.seezoon.application.device.dto.DeleteFenceCmd;
import com.seezoon.domain.service.device.DeviceFenceService;
import com.seezoon.infrastructure.configuration.context.SecurityContextHolder;
import com.seezoon.infrastructure.dto.Response;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

/**
 * 删除围栏执行器
 */
@RequiredArgsConstructor
@Slf4j
@Component
@Validated
public class DeleteFenceCmdExe {

    private final DeviceFenceService deviceFenceService;

    public Response execute(@Valid @NotNull DeleteFenceCmd cmd) {
        Long uid = SecurityContextHolder.get().getUid();
        deviceFenceService.deleteFence(cmd.getId(), uid);
        return Response.success();
    }
} 